package ca.compsci.opent.doctool;

/**
 * Models a variable in OpenT.
 * 
 * @since 0.0.2
 */
public class Var
{
	/**
	 * Variable's identifier in OpenT code.
	 * 
	 * @since 0.0.1a
	 */
	private String identifier;
	
	/**
	 * OpenT type that this variable is.
	 * 
	 * @since 0.0.2
	 */
	private Type type;

    /**
     * Creates a new {@code Var}.
     *
     * @param identifier the variables identifier in code
	 * @param type type that this variable is in OpenT code
	 * 
	 * @since 0.0.2
     */
    public Var(String identifier, Type type)
    {
        this.identifier = identifier;
		this.type = type;
    }

    /**
     * Returns this variable's identifier.
     *
     * @return variable's identifier in code
	 * 
	 * @since 0.0.1a
     */
    public String getIdentifier()
    {
        return identifier;
    }
	
	/**
	 * Returns the type of this variable.
	 * 
	 * @return type of this variable
	 * 
	 * @since 0.0.2
	 */
	public Type getType()
	{
		return type;
	}
	
	/**
	 * Returns a string representation.
	 * 
	 * <p>
	 * The representation is {@code var <i>identifier</i> : <i>type</i>}.
	 * </p>
	 * 
	 * @return string representation of this {@code Var}
	 * 
	 * @since 0.0.2
	 */
	@Override
	public String toString()
	{
		return "var " + identifier + " : " + type;
	}
}
